package com.bdweb.controller;

import com.bdweb.model.USER;

import com.bdweb.pojo.Result;
import com.bdweb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController  //添加到启动控制层

public class registerController {

    @Autowired
    private UserService userService;


    @CrossOrigin(origins = "*")   //设置跨域

     @PostMapping("/register")

    public Result addUser( USER user){
        System.out.println(user);
        Integer id = userService.addUser(user);

        return new Result(200,"success",id);
    }

    @GetMapping("/username")

    public Result getuser( Integer id ) {

   return new Result(200, "success",1);

    }
}
